package com.ruoyi.pidaijiData.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.pidaijiData.domain.plat.DataPidaijiChengzhong;
import com.ruoyi.pidaijiData.service.IDataPidaijiChengzhongService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 皮带机称重测试数据Controller
 * 
 * @author ruoyi
 * @date 2024-03-04
 */
@RestController
@RequestMapping("/pidaiji/chengzhong")
public class DataPidaijiChengzhongController extends BaseController
{
    @Autowired
    private IDataPidaijiChengzhongService dataPidaijiChengzhongService;

    /**
     * 查询皮带机称重测试数据列表
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:chengzhong:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataPidaijiChengzhong dataPidaijiChengzhong)
    {
        startPage();
        List<DataPidaijiChengzhong> list = dataPidaijiChengzhongService.selectDataPidaijiChengzhongList(dataPidaijiChengzhong);
        return getDataTable(list);
    }

    /**
     * 导出皮带机称重测试数据列表
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:chengzhong:export')")
    @Log(title = "皮带机称重测试数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataPidaijiChengzhong dataPidaijiChengzhong)
    {
        List<DataPidaijiChengzhong> list = dataPidaijiChengzhongService.selectDataPidaijiChengzhongList(dataPidaijiChengzhong);
        ExcelUtil<DataPidaijiChengzhong> util = new ExcelUtil<DataPidaijiChengzhong>(DataPidaijiChengzhong.class);
        util.exportExcel(response, list, "皮带机称重测试数据数据");
    }

    /**
     * 获取皮带机称重测试数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:chengzhong:query')")
    @GetMapping(value = "/{czId}")
    public AjaxResult getInfo(@PathVariable("czId") Long czId)
    {
        return success(dataPidaijiChengzhongService.selectDataPidaijiChengzhongByCzId(czId));
    }

    /**
     * 新增皮带机称重测试数据
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:chengzhong:add')")
    @Log(title = "皮带机称重测试数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataPidaijiChengzhong dataPidaijiChengzhong)
    {
        return toAjax(dataPidaijiChengzhongService.insertDataPidaijiChengzhong(dataPidaijiChengzhong));
    }

    /**
     * 修改皮带机称重测试数据
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:chengzhong:edit')")
    @Log(title = "皮带机称重测试数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataPidaijiChengzhong dataPidaijiChengzhong)
    {
        return toAjax(dataPidaijiChengzhongService.updateDataPidaijiChengzhong(dataPidaijiChengzhong));
    }

    /**
     * 修改皮带机称重测试数据
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:chengzhong:remove')")
    @Log(title = "修改皮带机称重测试数据", businessType = BusinessType.UPDATE)
    @PutMapping("/editChengzhong/{czId}")
    @ApiOperation(value="修改皮带机称重测试数据")
    public AjaxResult editChengzhong(@PathVariable Long czId)
    {
        return toAjax(dataPidaijiChengzhongService.updateDataPidaijiChengzhongByCzId(czId));
    }

    /**
     * 删除皮带机称重测试数据
     */
    @PreAuthorize("@ss.hasPermi('pidaiji:chengzhong:remove')")
    @Log(title = "皮带机称重测试数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{czIds}")
    public AjaxResult remove(@PathVariable Long[] czIds)
    {
        return toAjax(dataPidaijiChengzhongService.deleteDataPidaijiChengzhongByCzIds(czIds));
    }
}
